.PHONY: build clean api statics
VERSION := $(shell git rev-parse --abbrev-ref HEAD)
IMAGE_NAME := registry.cn-zhangjiakou.aliyuncs.com/aarch/apibe-web:$(VERSION)


run:
	@yarn run dev

build: clean
	@echo "Compiling source"
	npm run build
	@mv dist apibe-web
	@zip -r apibe-web.zip apibe-web

micro: build
	@echo "docker image $(IMAGE_NAME)"
	docker image inspect $(IMAGE_NAME) > /dev/null 2>&1 && docker rmi $(IMAGE_NAME) || true
	docker build -t $(IMAGE_NAME) -f ./Dockerfile .
	docker push $(IMAGE_NAME)

clean:
	@echo "Clean source"
	@rm -rf dist apibe-web.zip apibe-web

commit: build
	@ssh apibe "rm -rf /root/apibe/web/nginx/apibe-web"
	@scp apibe-web.zip apibe:/root/apibe/web/nginx
	@ssh apibe "unzip /root/apibe/web/nginx/apibe-web.zip -d /root/apibe/web/nginx"
